home *** CD-ROM | disk | FTP | other *** search
- class maze.elements.Pipe extends sarbakan.visual.element.DynamicElement
- {
- var mc;
- var bLastPipe;
- var oOwner;
- function Pipe(l_oLayer, l_oPipeInfos)
- {
- super("pipe" + sarbakan.visual.element.BaseElement.getNextID());
- var _loc5_ = l_oLayer.mc;
- this.mc = _loc5_.attachMovie("pipe","pipe" + sarbakan.visual.element.BaseElement.nNextID,maze.MazeData.DEPTH_PIPE + sarbakan.visual.element.BaseElement.nNextID);
- var _loc3_ = Math.random() * maze.MazeData.VIEW_TILE_WIDTH;
- if(_loc3_ < maze.MazeData.MARGIN_PIPE)
- {
- _loc3_ = maze.MazeData.MARGIN_PIPE;
- }
- if(_loc3_ > maze.MazeData.VIEW_TILE_WIDTH - maze.MazeData.MARGIN_PIPE)
- {
- _loc3_ -= maze.MazeData.MARGIN_PIPE;
- }
- this.mc._x = l_oPipeInfos.x * maze.MazeData.VIEW_TILE_WIDTH + _loc3_;
- this.mc._y = l_oPipeInfos.y * maze.MazeData.VIEW_TILE_HEIGHT;
- this.tile(l_oPipeInfos.height * maze.MazeData.VIEW_TILE_HEIGHT);
- this.mc.mcBottom._y = l_oPipeInfos.height * maze.MazeData.VIEW_TILE_HEIGHT;
- this.mc.mcBottom.swapDepths(9999999);
- this.bLastPipe = l_oPipeInfos.lastPipe;
- this.disable();
- }
- function enable()
- {
- super.enable();
- this.mc._visible = true;
- }
- function disable()
- {
- super.disable();
- this.mc._visible = false;
- }
- function remove()
- {
- super.remove();
- }
- function tile(l_nHeight)
- {
- var _loc4_ = this.mc.mcMiddle1._height;
- var _loc5_ = Math.round(l_nHeight / _loc4_);
- var _loc3_ = undefined;
- var _loc2_ = 1;
- while(_loc2_ < _loc5_)
- {
- _loc3_ = this.mc.mcMiddle1.duplicateMovieClip("mcMiddle" + _loc2_,this.mc.getNextHighestDepth());
- _loc3_._y += _loc2_ * (_loc4_ - 1);
- _loc2_ = _loc2_ + 1;
- }
- _loc3_._height *= _loc5_ - l_nHeight / _loc4_;
- }
- function idle()
- {
- if(this.collideWithElement("spongebob",this.mc.collider))
- {
- this.oOwner.oDynamicElements.spongebob.oCurrentPipe = this;
- this.setState("characterOn");
- }
- }
- function characterOn()
- {
- if(!this.collideWithElement("spongebob",this.mc.collider))
- {
- if(this.oOwner.oDynamicElements.spongebob.oCurrentPipe == this)
- {
- this.oOwner.oDynamicElements.spongebob.oCurrentPipe = undefined;
- }
- this.setState("idle");
- }
- }
- }
-